import service from './service';

export function postAction(url: string, parameter?: any, headers: any = {}): Promise<any> {
  return service.instance({
    url: url,
    method: 'post',
    data: parameter,
    headers
  })
}

export function getAction(url: string, parameter: any): Promise<any> {
  let headers: any = {}
  // if (this && parameter && this.realReferer && this.realReferer !== '') {
  //@ts-ignore
  if (this && this.realReferer && this.realReferer !== '') {
    //@ts-ignore
    headers.realReferer = window.location.origin + this.realReferer
  }
  return service.instance({
    url: url,
    method: 'get',
    params: parameter,
    headers
  });
}

//deleteAction
export function deleteAction(url: string, parameter: any): Promise<any> {
  return service.instance({
    url: url,
    method: 'delete',
    params: parameter
  })
}

//put
export function putAction(url: string, parameter: any): Promise<any> {
  return service.instance({
    url: url,
    method: 'put',
    data: parameter
  })
}